package com.iqismart.shorturl.vo.base;

import com.iqismart.shorturl.exception.BaseException;

import java.io.Serializable;

/**
 * @Description
 * @Auther sty
 * @createTime 2019/10/14 01:38
 */
public class Result<T> implements Serializable {
    public Integer code = 0;
    public Long count = 0L;
    public T data;
    public String message;
    public String description;

    public Result() {
    }

    public Result(T data) {
        this.data = data;
    }

    public Result(BaseException ex) {
        this.code = ex.code;
        this.message = ex.message;
        this.description = ex.description;
    }

    public Result(Integer code, T data, String message, String description) {
        this.code = code;
        this.data = data;
        this.message = message;
        this.description = description;
    }

    public static Result succeed() {
        Result result = new Result();
        return result;
    }

    public static Result succeed(String msg) {
        Result result = new Result();
        result.message = msg;
        return result;
    }

    public static Result failed(String msg) {
        Result result = new Result();
        result.code = -1;
        result.message = msg;
        return result;
    }
}

